package com.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class JDBCUtil {
    private static String driver="com.mysql.jdbc.Driver";
    private static String url="jdbc:mysql://master:3306/csw";
    private static String username="root";
    private static String password="123456";
    static {
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConnection()throws Exception{
        Connection connection = DriverManager.getConnection(url, username, password);
        return connection;
    }
    public static void closeALL(PreparedStatement ps,Connection connection)throws Exception{
        ps.close();
        connection.close();
    }
    public static void closeALL(ResultSet rs,PreparedStatement ps, Connection connection)throws Exception{
        ps.close();
        connection.close();
    }
}
